package com.njwb.subject.mapper;

import com.njwb.subject.entity.Subject;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SubjectMapper {
    void add(Subject subject);

    /**
     * 根据学号查询课题信息
     * @param stuNo
     * @return
     */
    Subject getByNo(String stuNo);

    /**
     * 查询未被选中的课题数量
     * @return
     */

    @Select("select count(0) as cnt from t_subject where status = 0" )
    int getFreeCnt();


    /**
     * 查询课题id最小值
     * @return
     */
    @Select("select min(t_id) from t_subject")
    int getMinId();

    /**
     * 查询课题id最大值
     * @return
     */
    @Select("select max(t_id) from t_subject")
    int getMaxId();

    /**
     * 查询所有空闲的课题id
     * @return
     */
    @Select("select t_id from t_subject where status = 0")
    List<Integer> getFreeIds();

    void update(Subject subject);

}
